package com.ds.lens.data.service.dao.sql.provider;

import com.ds.lens.data.service.dao.entity.LensMonitor;
import org.apache.ibatis.jdbc.SQL;

public class LensMonitorSqlProvider {

    public String insertSelective(LensMonitor record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("lens_monitor");

        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }

        if (record.getName() != null) {
            sql.VALUES("name", "#{name,jdbcType=VARCHAR}");
        }

        if (record.getIntegrationId() != null) {
            sql.VALUES("integration_id", "#{integrationId,jdbcType=BIGINT}");
        }

        if (record.getDetectionMethod() != null) {
            sql.VALUES("detection_method", "#{detectionMethod,jdbcType=TINYINT}");
        }

        if (record.getApplicationId() != null) {
            sql.VALUES("application_id", "#{applicationId,jdbcType=BIGINT}");
        }

        if (record.getState() != null) {
            sql.VALUES("state", "#{state,jdbcType=SMALLINT}");
        }

        if (record.getMute() != null) {
            sql.VALUES("mute", "#{mute,jdbcType=BIT}");
        }

        if (record.getMuteStartTime() != null) {
            sql.VALUES("mute_start_time", "#{muteStartTime,jdbcType=TIMESTAMP}");
        }

        if (record.getMuteEndTime() != null) {
            sql.VALUES("mute_end_time", "#{muteEndTime,jdbcType=TIMESTAMP}");
        }

        if (record.getIsDelete() != null) {
            sql.VALUES("is_delete", "#{isDelete,jdbcType=BIT}");
        }

        if (record.getRunStatus() != null) {
            sql.VALUES("run_status", "#{runStatus,jdbcType=TINYINT}");
        }

        if (record.getTags() != null) {
            sql.VALUES("tags", "#{tags,jdbcType=VARCHAR}");
        }

        if (record.getVersion() != null) {
            sql.VALUES("version", "#{version,jdbcType=INTEGER}");
        }

        if (record.getCreator() != null) {
            sql.VALUES("creator", "#{creator,jdbcType=VARCHAR}");
        }

        if (record.getCreatedTime() != null) {
            sql.VALUES("created_time", "#{createdTime,jdbcType=TIMESTAMP}");
        }

        if (record.getMender() != null) {
            sql.VALUES("mender", "#{mender,jdbcType=VARCHAR}");
        }

        if (record.getModifiedTime() != null) {
            sql.VALUES("modified_time", "#{modifiedTime,jdbcType=TIMESTAMP}");
        }

        if (record.getVersionTime() != null) {
            sql.VALUES("version_time", "#{versionTime,jdbcType=TIMESTAMP}");
        }

        return sql.toString();
    }

    public String updateByPrimaryKeySelective(LensMonitor record) {
        SQL sql = new SQL();
        sql.UPDATE("lens_monitor");

        if (record.getName() != null) {
            sql.SET("name = #{name,jdbcType=VARCHAR}");
        }

        if (record.getIntegrationId() != null) {
            sql.SET("integration_id = #{integrationId,jdbcType=BIGINT}");
        }

        if (record.getDetectionMethod() != null) {
            sql.SET("detection_method = #{detectionMethod,jdbcType=TINYINT}");
        }

        if (record.getApplicationId() != null) {
            sql.SET("application_id = #{applicationId,jdbcType=BIGINT}");
        }

        if (record.getState() != null) {
            sql.SET("state = #{state,jdbcType=SMALLINT}");
        }

        if (record.getRunStatus() != null) {
            sql.SET("run_status = #{runStatus,jdbcType=TINYINT}");
        }

        if (record.getMute() != null) {
            sql.SET("mute = #{mute,jdbcType=BIT}");
        }

        if (record.getMuteStartTime() != null) {
            sql.SET("mute_start_time = #{muteStartTime,jdbcType=TIMESTAMP}");
        }

        if (record.getMuteEndTime() != null) {
            sql.SET("mute_end_time = #{muteEndTime,jdbcType=TIMESTAMP}");
        }

        if (record.getIsDelete() != null) {
            sql.SET("is_delete = #{isDelete,jdbcType=BIT}");
        }

        if (record.getTags() != null) {
            sql.SET("tags = #{tags,jdbcType=VARCHAR}");
        }

        if (record.getVersion() != null) {
            sql.SET("version = #{version,jdbcType=INTEGER}");
        }

        if (record.getCreator() != null) {
            sql.SET("creator = #{creator,jdbcType=VARCHAR}");
        }

        if (record.getCreatedTime() != null) {
            sql.SET("created_time = #{createdTime,jdbcType=TIMESTAMP}");
        }

        if (record.getMender() != null) {
            sql.SET("mender = #{mender,jdbcType=VARCHAR}");
        }

        if (record.getModifiedTime() != null) {
            sql.SET("modified_time = #{modifiedTime,jdbcType=TIMESTAMP}");
        }
        if (record.getVersionTime() != null) {
            sql.SET("version_time = #{versionTime,jdbcType=TIMESTAMP}");
        }

        sql.WHERE("id = #{id,jdbcType=BIGINT} and is_delete = 0");

        return sql.toString();
    }
}
